package cn.tedu.csmall.stock.webapi.quartz;

import cn.tedu.csmall.stock.webapi.quartz.config.RabbitMQConfiguration;
import cn.tedu.csmall.stock.webapi.untils.RedisBloomUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

public class QuartzJob implements Job {
    @Autowired

    private RedisBloomUtils redisBloomUtils;


    @Autowired
    //RabbitTemplate能够向rabbitMQ发送信息
    private RabbitTemplate rabbitTemplate;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        System.out.println("---------------"+ LocalDateTime.now()+"--------------");
        //先简单的发一个字符串
        //convertAndSend指定三个参数,交换机名称,路由key名称,发送信息
        rabbitTemplate.convertAndSend(RabbitMQConfiguration.STOCK_EX,RabbitMQConfiguration.STOCK_ROUT,"接收到减库存的消息");





        /*
        //先将要添加到布隆过滤器的元素保存到一个数组中
        String[] colors={"red","orange","yellow","green","blue","black"};
        //将上面集合中的元批量新增到布隆过滤器中
        redisBloomUtils.bfmadd("color",colors);
        //定义一个要判断是否在集合中的元素
        String elm="pink";
        System.out.println("布隆过滤器判断"+elm+"是否在集合中:"+redisBloomUtils.bfexists("color",elm));

         */



    }
}
